(function ($){
    Drupal.behaviors.studentlist = {
        attach: function(context, settings) {
            $('#edit-class').change(function(){
                for(j = 1; j <= 19; ++j){
                    $('#edit-listavailable-'+j).attr('checked', false);
                }
                
            });
            
            $('#edit-listavailable-0').attr('disabled', true);
            $('#edit-listavailable-0').attr('checked', true);
            $('#edit-listavailable-1').hide();
            $("label[for='edit-listavailable-1']").hide();
            $('#edit-listavailable-2').attr('checked', true);
            $('#edit-listavailable-3').attr('checked', true);
            $('#edit-listavailable-14').hide();
            $("label[for='edit-listavailable-14']").hide();
            for (i = 3; i <= 19;++i){
                $('#tableresult td:nth-child('+i+'),th:nth-child('+i+')').hide();
            }
            $('#tableresult td:nth-child(4),th:nth-child(4)').show(); 
            $('#tableresult td:nth-child(5),th:nth-child(5)').show(); 
            
            $('#tableresult td:nth-child(16),th:nth-child(16)').show();            
            for(j = 1; j <= 19; ++j){
                $('#edit-listavailable-'+j).click(function(){
                    var my_id = $(this).attr('id');
                    var length = my_id.length;
                    var id_num = my_id.substring(19, length);
                    var k = parseInt(id_num, 10) + 2;
                                      
                    if (this.checked){
                        $('#tableresult td:nth-child('+ k +'),th:nth-child('+ k + ')').show();
                       
                    }else{
                        $('#tableresult td:nth-child('+ k  +'),th:nth-child('+ k+')').hide();
                      
                    }
                                       
                }); 
            }                      
        }
    }
}(jQuery));
            
           